home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE6 / PD / PDF / GuiLib / GuiFlex / h / GuiFlexDA < prev    next >
Text File  |  2003-02-14  |  3KB  |  89 lines

  1. //--------------------------------------------------------------------------
  2. //
  3. //   Copyright (c) 2002, Colin Granville
  4. //
  5. //   All rights reserved.
  6. //
  7. //   Redistribution and use in source and binary forms, with or
  8. //   without modification, are permitted provided that the following 
  9. //   conditions are met:
  10. //
  11. //      * Redistributions of source code must retain the above copyright 
  12. //        notice, this list of conditions and the following disclaimer.
  13. //
  14. //      * Redistributions in binary form must reproduce the above 
  15. //        copyright notice, this list of conditions and the following 
  16. //        disclaimer in the documentation and/or other materials 
  17. //        provided with the distribution.
  18. //
  19. //      * The name Colin Granville may not be used to endorse or promote 
  20. //        products derived from this software without specific prior 
  21. //        written permission.
  22. //
  23. //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  24. //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  25. //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  26. //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  27. //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  28. //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  29. //   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  30. //   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  31. //   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  32. //   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  33. //   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
  34. //   OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //--------------------------------------------------------------------------
  37.  
  38. #ifndef GuiFlexDA_h
  39. #define GuiFlexDA_h
  40.  
  41. #include "GuiFlex.h"
  42. #include "GuiAtExit.h"
  43.  
  44. class GuiFlexDA : public GuiFlex, private GuiAtExit
  45. {
  46.   public:
  47.     GuiFlexDA(const char *name, int *error_fd, int dynamic_size);
  48.     virtual         ~GuiFlexDA();
  49.     virtual bool    alloc(GuiFlexAnchor&,size_t n);
  50.     virtual bool    free(GuiFlexAnchor&);
  51.     virtual size_t  size(const GuiFlexAnchor&) const;
  52.     virtual bool    extend(GuiFlexAnchor&,size_t new_size);
  53.     virtual bool    midExtend(GuiFlexAnchor&,size_t at,int by);
  54.     virtual bool    reanchor(GuiFlexAnchor& to, GuiFlexAnchor& from);
  55.     virtual bool    setBudge(bool on);
  56.     virtual void    saveHeapInfo(char* filename); 
  57.     virtual bool    compact();
  58.     virtual bool    setDeferredCompaction(bool on);
  59.     virtual size_t  availableMemory();
  60.     
  61.     bool            isOk() const    {return base != 0;}
  62.  
  63.   private:
  64.  
  65.     struct Object
  66.     {
  67.       size_t         size;
  68.       GuiFlexAnchor* anchor;
  69.  
  70.       size_t         capacity()     {return ((size+3)&~3);}
  71.     };
  72.  
  73.     char*           base;
  74.     int             number; 
  75.     size_t          top;
  76.     size_t          end;
  77.     size_t          maxSize;
  78.  
  79.     virtual void    atExit();
  80.     bool            resize(size_t new_size);
  81.     Object*         getObject(const GuiFlexAnchor&) const;
  82.     static          void setAnchor(GuiFlexAnchor&,Object*);
  83.     void            reanchor(Object* from);
  84.     Object*         topObject();
  85.     Object*         nextObject(Object*);
  86. };
  87.  
  88. #endif
  89.